<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <%- include common %>
        <style>
            .layui-layout-body {
                padding-top: 0;
            }
        </style>
</head>

<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <%- include head  %>


        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div style="padding: 15px;">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col width="150">
                    </colgroup>
                    <thead>
                        <tr>
                            <th>房间编号</th>
                            <th>房间类型</th>
                            <th>房间食物</th>
                            <th>房间价格</th>
                            <th>房间电话</th>
                            <th>房间状态</th>
                            <th>房间alt</th>
                            <th>房间id</th>
                            <th>修改详情</th>
                            <th>删除房间</th>
                        </tr>
                    </thead>
                    <tbody>
                        <% if(data.length>0){ %>
                            <% data.forEach((item,i)=>{ %>
                                <tr>
                                    <td>
                                        <%- item.rnum %>
                                    </td>
                                    <td>
                                        <%- item.type %>
                                    </td>
                                    <td>
                                        <%- item.food %>
                                    </td>
                                    <td>
                                        <%- item.moeny %>
                                    </td>
                                    <td>
                                        <%- item.phone %>
                                    </td>
                                    <td>
                                        <%- item.state %>
                                    </td>
                                    <td>
                                        <%- item.alt %>
                                    </td>
                                    <td>
                                        <%- item.id %>
                                    </td>
                                    <td>
                                        <button onclick="location.href='/room/roomupdate/?_id=<%- item._id %>'" class="layui-btn">修改</button>
                                    </td>
                                    <td>
                                        <button onclick="deleteone('<%- item._id %>')" class="layui-btn">移除</button>
                                    </td>
                                </tr>
                                <% }) %>
                                    <% } %>
                    </tbody>
                </table>
            </div>
        </div>

        <div class="layui-footer">
            <!-- 底部固定区域 -->
            © 国际大酒店 layumen.com
        </div>
    </div>
    <!-- <script src="../src/layui.js"></script> -->
    <script>
        //JavaScript代码区域
        layui.use('element', function () {
            var element = layui.element;

        });
        function deleteone(_id) {
            layer.confirm('确认删除？', {
                btn: ['删除', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: '/room/removeone',
                    type: 'get',
                    data: {
                        _id
                    },
                    success: res => {
                        if (res.code == 200) {
                            $(this).parent().parent().remove();
                            layer.msg('删除', { icon: 1 });
                            setTimeout(() => {
                                window.location.reload()
                            }, 2000);
                        }
                    }
                })
                layer.msg('删除', { icon: 1 });
            }, function () {
                layer.msg('取消', {
                    time: 2000, //20s后自动关闭
                });
            });
        }
    </script>
</body>

</html>